﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Xml;

namespace AIC_CD
{
    public partial class XemBaoCaoSoLieuTinhHinhHoatDongCongDoan : MyFromBase
    {
        private int DonViID;
        private int KyBaoCao;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["DonViID"] != null)
            {
                DonViID = Convert.ToInt32(Session["DonViID"]);
            }
            if (Session["KyBaoCao"] != null)
            {
                KyBaoCao = Convert.ToInt32(Session["KyBaoCao"]);
            }
            BindDataToGrid(DonViID, KyBaoCao);
        }

        private void BindDataToGrid(int DonViID, int KyBaoCao)
        {
            //TODO

            string sql = "Select BC.* From tblPhuLucSoLieuTinhHinhHoatDongCongDoan BC " +
                            "Inner Join tblDonVi DV On DV.ID=BC.DonViID " +
                            "Inner Join tblUser U On U.DonViID=DV.ID " +
                            "Where BC.IsCommon<>1 And U.ID=" + Session["userid"] + " And BC.KyBaoCaoID_DM=" + KyBaoCao;
            grvData.DataSource = SqlHelper.ExecuteDataTable(System.Data.CommandType.Text, sql);
            grvData.DataBind();

            //sql = "Select BC.* From tblPhuLucSoLieuTinhHinhHoatDongCongDoan BC " +
            //             "Inner Join tblDonVi DV On DV.ID=BC.DonViID " +
            //             "Inner Join tblUser U On U.DonViID=DV.ID " +
            //             "Where BC.IsCommon=1 And U.ID=" + Session["userid"] + " And BC.KyBaoCaoID_DM=" + cboKyBaoCao.SelectedValue;
            DataTable temDT = SqlHelper.ExecuteDataTable(System.Data.CommandType.Text, sql);
            if (temDT.Rows.Count > 0)
            {
                txtTenBaoCao.Text = temDT.Rows[0]["CM_TenBaoCao"].ToString();
                txtThoiGianBaoCao.Text = temDT.Rows[0]["CM_ThoiGianBaoCao"].ToString();
                //txtThuTruongCoQuanChinhTri.Text = temDT.Rows[0]["CM_ThuTruong"].ToString();
            }

            //btnLuu.Visible = true;


        }

        #region Events

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("Index.aspx");
        }

        #endregion Events


        #region GridCommand

        protected void grvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //grvData.PageIndex = e.NewPageIndex;
            //BindDataToGrid();
        }
        #endregion GridCommand
    }
}
